import java.util.Arrays;
import java.util.Scanner;

public class BubbleSort {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int[] a = { 24, 7, 18, 56, 33 };
        bubbleSort(a);
        System.out.println(Arrays.toString(a));
    }

    public static void bubbleSort(int[] a) {
        int paragon = 0;
        int tool = 0;

        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a.length - 1 - i; j++) {
                if (a[j] > a[j + 1]) {
                    tool = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = tool;
                    paragon = 1;
                }
            }

            if (paragon == 0) {
                break;
            }
            paragon = 0;
        }
    }
}
